﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using TrafficWatcher.Infrastructure;
using TrafficWatcher.Models;
using TrafficWatcher.Models.DirectionsProvider;
using TrafficWatcher.ViewModels.Helpers;

namespace TrafficWatcher
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private readonly ShutdownService shutdownService;
    
        public App()
        {
            DirectionsProviderRepository = new DirectionsProviderRepository();
            new List<IDirectionsProvider> { new BingMaps(), new GoogleMaps(), new NokiaHere(), new YandexMaps() }.ForEach(DirectionsProviderRepository.AddDirectionsProvider);

            EnvironmentContext = new WindowsContext();
            Settings = Settings.Load(EnvironmentContext, DirectionsProviderRepository);
            DirectionDurationService = new DirectionDurationService(Settings);

            shutdownService = new ShutdownService {EnvironmentContext = EnvironmentContext};

            DirectionDurationService.Enabled = true;
        }

        public IEnvironmentContext EnvironmentContext { get; private set; }
        public Settings Settings { get; private set; }
        public DirectionsProviderRepository DirectionsProviderRepository { get; private set; }
        public IDirectionDurationService DirectionDurationService { get; private set; }
    }
}
